public class Solution2319 {
    public boolean checkXMatrix(int[][] grid) {
        for (int i=0;i<grid.length;i++){
            if (grid[i][i]==0){
                return false;
            }
            if (grid[i][grid.length-i-1]==0){
                return false;
            }
            for (int j=0;j<grid.length;j++){
                if (i!=j && j!=grid.length-i-1){
                    if (grid[i][j]!=0){
                        return false;
                    }
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution2319().checkXMatrix(new int[][]{{2,0,0,1},{0,3,1,0},{0,5,2,0},{4,0,0,2}}));
    }
}
